<%@include file="package.jsp" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>更新学生信息</title>
<style type="text/css">

input {
width: 100px;
}
</style>
</head>
<body>
<%@include file="includ.jsp" %>
<%
String X=null;
long stuno=Long.parseLong(request.getParameter("stuno"));
StudentSerive ss=new StudentSerive();
Student stu=ss.serch1(stuno);
%>
<form action="upStudentBaoCun.jsp"  method="post" enctype="multipart/form-data">
<p>
	<label>学号</label>
	<input type="text"  name="stuno" value="<%=stu.getStuno()%>" readonly="readonly"/>
	
	</p>
	<label>姓名</label>
	<input type="text"  name="sname" value="<%=stu.getSname()%>"/>
	
	</p>
	<p>
	<label>性别</label>
	<%
	if(stu.getSex().equals("男")){
	%>
	<input type="radio"  name="sex" value="男" checked="checked"/>男
	<%}else{ %>
	<input type="radio"  name="sex" value="男" />男
	<%} %>
	<%
	if(stu.getSex().equals("女")){
	%>
	<input type="radio"  name="sex" value="女" checked="checked"/>女
		<%}else{ %>
		<input type="radio"  name="sex" value="女"/>女
	<%} %>
		<%
	if(stu.getSex().equals("妖")){
	%>
	<input type="radio"  name="sex" value="妖" checked="checked"/>妖
	<%}else{ %>
	<input type="radio"  name="sex" value="妖"/>妖
	<%} %>
			<%
	if(stu.getSex().equals("妖")){
	%>
	<input type="radio"  name="sex" value="人妖" checked="checked"/>人妖
	<%}else{ %>
	<input type="radio"  name="sex" value="人妖"/>人妖
	<%} %>
	</p>
	<p>
	<label>电话</label>
	<input type="text" required name="telephone" value="<%=stu.getTelephone()%>"/>
	</p>
	<p>
	<label>qq</label>
	<input type="text" required name="qq" value="<%=stu.getQq()%>"/>
	</p>
	<p>
	<label>微信</label>
	<input type="text" required name="wechat" value="<%=stu.getWechat()%>"/>
	</p>
	<p>
	<label>年级</label>
	
	<select required name="gradeid">
	<%
	GradeSerive gs=new GradeSerive();
	List<Grade> list=gs.findAll();
	for(Grade g:list){
		if(stu.getGradeid()==g.getId()){
	%>
	<option value="<%=g.getId() %>" selected="selected"><%=g.getId() %></option>
	<%} %>
	<option value="<%=g.getId() %>"><%=g.getId() %></option>
	<%} %>
	</select>
	</p>
	<p>
	<label>入学日期</label>
	<%
	SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
	if(stu.getEnterdate()==null){
		
		X="";
	}
	%> 

	<input type="text" required name="enterdate" value="<%=stu.getEnterdate()==null?X:format.format(stu.getEnterdate()) %>"/>
	</p>
	<p>
	<label>来自哪个城市</label>
	<input type="text" required name="fromcity" value="<%=stu.getFromcity()%>"/>
	</p>
	<p>
	<label>生日</label>

	<input type="text" required name="birthday" value="<%=stu.getBirthday()==null?X:format.format(stu.getBirthday())%>"/>
	</p>
	<p>
	<label>地址</label>
	<input type="text" required name="address" value="<%=stu.getAddress()%>"/>
	</p>
	<p>
	<label>密码</label>
	<input type="text" required name="pass" value="<%=stu.getPass()%>"/>
	</p>
    <p>
	<label>照片</label>
	<input type="file" id="file"  onchange="changepic(this)" name="pic" accept=""/> 
	</p>
	<p>
    <input type="submit" value="修改"/>
   </p>
</form>
<img id="photo" name="photo" src="../<%=stu.getPhoto()%>">	
</body>
<script type="text/javascript">
function changepic(obj) {
	 document.getElementById("photo").src= window.webkitURL.createObjectURL(obj.files[0]);
}
</script>
</html>